home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-21 | 3.0 KB | 92 lines | [TEXT/MPS ] |
- ;
- ;
- ; Copyright © 1991, Apple Computer, Inc.
- ;
- ; by Rob Glanville
- ;
- ; 15 May 91
- ;
- ; JG_prolog.a - Startup assembly code
- ;
- ;
- ; Memory Map - 512kb assumed
- ; 00000000 - 000003FF = Interrupt Vectors
- ; 00000400 - 000005FF = Command buffer
- ; 00000600 - 00007FFF = Stack
- ; 00008000 - 0000FFFF = Data
- ; 00010000 - 00017FFF = Code
- ; 00018000 - 0007FFFF = Free memory
- ; 00080000 - 00FFFFFF = Memory mapped I/O
- ;
- ; Since this code is linked in with the application that uses it, the
- ; A5 data reference changes every time variables are added or subtracted.
- ; To pin down the data for this code, A5 is adjusted so the top of the
- ; data is always at 10000. It's tricky so don't fool with it!
- ; The main purpose of this code is to provide a stable environment for
- ; the C code to start with. All the real work should be done in C.
- ; Try not to modify this code if possible, it is just a bridge.
- ;
- ; How this works;
- ; 1) The stack and data reference registers are initialized
- ; 2) The data segment is cleared
- ; 3) A key word is used to signal the Mac we're ready to go
- ; 4) We wait for a test command before jumping to the C code
-
- TOS equ $18000 ; Top of stack
- TOD equ $fffe ; Top of Data
- ClearCount equ $3FE ; Clear this many 32 bit words
- VectorCount equ $fe ; Number of vector pointers
- Null equ $00000000 ; Zero
- InitialSR equ $2700 ; Initial status register
- ClearStart equ $00000008 ; After the reset vector
- Pattern equ $00000000 ; Clear memory pattern
- GreenLight equ $00500000 ; Green light control
- RedLight equ $00400000 ; Green light control
- SmartMode equ $00600000 ; Smart mode control
-
- import COMMANDLOOP
-
- Begin proc export
- data
- import TopOfData ; First variable in C code
- code
- move.w #InitialSR,sr ; Clear interrupts
- move.l #TOS,sp ; Set up the stack pointer
- move.b $CA000C,d0 ; Reset and clear
- move.b $CA0008,d0 ; Reset and clear
- move.b $C00004,d0 ; Reset and clear
- move.b $C00002,d0 ; Reset and clear
- move.b #$00,$CA000D ; Reset and clear
- move.b #$87,$CA000F ; Reset and clear
- move.w #$0000,$CA0008 ; Reset DMA control register
- move.w SmartMode,d0 ; Select smart mode
- move.w RedLight,d0 ; Turn on red light
- move.w d0,GreenLight ; Turn off green light
- move.l #TOD,d0 ; Set up data pointer
- move.l #Null,a5 ; Set up data pointer
- lea TopOfData,a0 ; Get address
- move.l a0,d1 ; Copy
- sub.l d1,d0 ; Adjust
- move.l d0,a5 ; Set the data offset
- move.l #ClearCount,d0 ; Set data size
- move.l #ClearStart,a0 ; Clear pointer
- clear move.l #Pattern,(a0)+ ; Zap memory
- dbra d0,clear ; Loop back until done
- lea UnusedInterrupt,a1 ; Get the pointer
- move.l #VectorCount,d0 ; Set vector count
- move.l #ClearStart,a0 ; Clear pointer
- Zap move.l a1,(a0)+ ; Zap memory
- dbra d0,Zap ; Loop back until done
- move.w GreenLight,d0 ; Turn on green light
- move.w d0,RedLight ; Turn off red light
- bra.w COMMANDLOOP ; Enter the C code
- bra.w Begin ; Start over if we ever return
-
- UnusedInterrupt
- move.l #'Int0',$0 ; Set the error flag
- rte ; Interrupt return
-
- endp ; End of procedure
- end ; End of source
-
-